<template>
  <template v-for="(bItem, bIndex) in buttonInfo" :key="bIndex">
    <!-- 常用按钮 删除 -->
    <el-button
      v-if="bItem.name.includes('delete')"
      :type="bItem.type"
      @click="remove(rowData)"
    >
      {{ bItem.label }}
    </el-button>
  </template>
</template>

<script>
export default {
  name: "ButtonGroup",
  props: {
    buttonInfo: {
      required: true,
      type: Array
    },
    rowData: {
      required: true,
      type: Object
    }
  },
  setup(props, ctx) {
    const remove = (rowData) => {
      vm.$confirm("此操作将永久删除该数据, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          // vm.$message({
          //   type: "success",
          //   message: "删除成功!"
          // });
          ctx.emit("customRemove", rowData);
        })
        .catch(() => {
          vm.$message({
            type: "info",
            message: "已取消删除"
          });
        });
    };
    return {
      remove
    };
  }
};
</script>
